/**
 * 
 */
package com.mc.date;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;

/**
 * @author w.weizhen
 *
 */
public class LocalDateTimeTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) 
	{
//		String valid_beginTime = "1970-01-01 00:00:00";// 有效期；最早时间"1970-01-01T00:00:00"
//	    String valid_endTime = "2037-12-31 23:59:59";// 有效期；最晚时间"2037-12-31T23:59:59"
//		String pattern = null;
//	    pattern = "yyyy-MM-dd HH:mm:ss";
//	    
//	    DateTimeFormatter dtf = DateTimeFormatter.ofPattern(pattern);
//	    LocalDateTime ldt1 = LocalDateTime.parse(valid_beginTime, dtf);
//	    LocalDateTime ldt2 = LocalDateTime.parse(valid_endTime, dtf);
//	    
//	    pattern = "yyyy-MM-dd'T'HH:mm:ss";
//	    DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern(pattern);
//	    
//	    System.out.println(ldt1.format(dtf2));
//	    System.out.println(ldt2.format(dtf2));
//	    System.out.println(ldt1.isAfter(ldt2));
	    
//	    System.out.println(ldt1.format(DateTimeFormatter.ofPattern(pattern)));
	    
//	    DateTimeFormatter df1 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
//	    LocalDateTime ldt3 = LocalDateTime.parse("2019-12-07 21:20:06", df1);
	    
		
//	    // LocalDate转LocalDateTime
//	    String date = "2023-02-15";
//	    LocalDate localdate = LocalDate.parse(date);
//	    LocalDateTime dateTime_ldt = localdate.atStartOfDay();
//	    DateTimeFormatter dateTime_dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
//	    String dateTime = dateTime_ldt.format(dateTime_dtf);
//	    System.out.println(dateTime);
//	    
//	    // LocalDateTime得到时间戳
//	    Long epochMilli = LocalDateTime.from(dateTime_ldt).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
//	    System.out.println(epochMilli);
	    
		
//	    // LocalDateTime 得到一天开始日期时间和结束日期时间
//		String date = "2023-02-21";
//	    //LocalDate localdate = LocalDate.parse(date);
//	    //LocalDateTime dateTime_ldt = localdate.atStartOfDay();
//	    LocalDateTime dateTime_ldt_start = LocalDateTime.of(LocalDate.parse(date), LocalTime.MIN);
//	    LocalDateTime dateTime_ldt_end = LocalDateTime.of(LocalDate.parse(date), LocalTime.MAX);
//	    DateTimeFormatter dateTime_dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss+08:00");
//	    String dateTime_start = dateTime_ldt_start.format(dateTime_dtf);
//	    String dateTime_end = dateTime_ldt_end.format(dateTime_dtf);
//	    System.out.println(dateTime_start);
//	    System.out.println(dateTime_end);
	    
	    
//	    LocalDate today = LocalDate.now();
//	    DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd");
//	    String dateStr = today.format(fmt);
//	    System.out.println(dateStr);
	    
//		// LocalDateTime 转 LocalTime
//		String dateTime = "2023-02-20T01:00:00";
//		LocalDateTime ldt2 = LocalDateTime.parse(dateTime);
//		String hh = ldt2.format(DateTimeFormatter.ofPattern("HH"));
//		System.out.println(hh);
//		System.out.println(Integer.parseInt(hh));
		
	    
	    
	    // LocalDateTime 得到一天开始日期时间和结束日期时间
	    DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        LocalDate today = LocalDate.now();
        LocalDateTime ldt= LocalDateTime.of(today, LocalTime.MIN);
        //授权时间 结束时间
        System.out.println(ldt.format(dtf));
        ldt = LocalDateTime.of(today.plusDays(365), LocalTime.MAX);
        System.out.println(ldt.format(dtf));
        
	}

}